var syntaxStates = ['text', 'innerspace', 'text', 'text', 'innerspace'];

function loadProperty(){
	var info = window.info;
	
	$('name-field').value = info['name'];
	$('owner-field').value = info['owner'];
	$('type-select').selectedIndex = info['eval_type']
	
	$('codepress').contentWindow.CodePress.setCode(syntaxStates[info['eval_type']], info['value']);
}

function saveProperty(){
	var info = {};
	info['name'] = $('name-field').value;
	info['owner'] = $('owner-field').value;
	info['eval_type'] = $('type-select').selectedIndex;

	info['value'] = $('codepress').contentWindow.CodePress.getCode();
	
	window.resultDeferred.callback(info);
	window.close();
}

function cancelProperty(){
	window.resultDeferred.callback(null);
	window.close();
}

function toggleSyntax(type){
	var codepress = $('codepress').contentWindow.CodePress;
	codepress.setCode(syntaxStates[type], codepress.getCode());
}

function requestACLEditor(){
	var connector = window.clientWindow.getConnector();
	var deferred = connector.callRemote('req_acl_editor', window.info['id'], window.info['name']);
	return deferred;
}